#include "vector_float.h"
#include <iostream>


vector_float::vector_float(void)
{
	create_vector(0); 
	this->vptr = nullptr;
}

vector_float::vector_float( int s )  
{ 
	create_vector(s); 
}


vector_float::~vector_float(void)
{
}


void vector_float::create_vector( int s )
{
	this->vptr = new float[s];
	this->size = s;
}

void vector_float::delete_vector()
{
	delete [] vptr;
	this->size = 0;
}


void vector_float::set( float value, int index )
{
	if( (index >= 0) && (index < this->size) )
	{
		this->vptr[index] = value;
	}
	else
	{
		std::cout << "Index is out of bounds\n";
	}
}

void vector_float::read_from_keyboard()
{
	float temp;

	if( this->size == 0 )
		return;

	for( int i = 0; i < this->size; i++ )
	{
		std::cout << "\nWrite a float to put at position " << i << " : ";
		std::cin >> temp;
		set( temp, i );
	}
}

void vector_float::print()
{
	if( this->size == 0 )
		return;
	std::cout << "[";
	for( int i = 0; i < this->size -1 ; i++ )
	{
		std::cout << this->vptr[i] << ",";
	}
	std::cout << this->vptr[size-1];
	std::cout << "]";
}